<?php
Yii::import('application.components.dao.class.Dao');
/**
 * 
 * @author luhaoz-work
 * @property Array $images
 */
class ProductDao extends Dao{
    
    public function dataSource(){
        return array(
            'ProductInfo' => array(
                'attributes'    => array(
                    'id','title','tag','short_description','description','created'
                ),                
            ),
            'ProductFee' => array(
                'attributes'    => array(
                    'value_price','auction_fee','shipping_fee','billing_fee','bids'
                ),
            ),
            'ProductParame' => array(
                'attributes'    => array(
                    'meta_title','meta_keywords','url','meta_description'
                ),
            ),
            'ProductCategoryRelations' => array(
                'attributes'    => array(
                    'category_id','category_title'
                ),
            ),
            'ProductResourceDao'   => array(
                'attributes'    => array(
                    'images'
                ),
            )
        );
    }
    
    public function rules(){
        return array(
           array('category_title','exist','className'=>'Category','attributeName' => 'title','message'=>'Category is not find!'),
           array('category_title,value_price,auction_fee,shipping_fee,billing_fee','required')  ,
           array('value_price,auction_fee,shipping_fee,billing_fee','numerical'),
        );
    }
    
    public function dataSourceRelations(){
        return array(
            'ProductInfo'     => array(
                'ProductFee'                => array('part','join' => array('id' => 'product_id')),
                'ProductParame'             => array('part','join' => array('id' => 'product_id')),
                'ProductCategoryRelations'  => array('part','join' => array('id' => 'product_id')),
                'ProductResourceDao'        => array('part','join' => array('id' => 'product_id')),
            ),
        );
    }
}